<template>
  <el-dialog v-if="visible" :title="info.title" :visible.sync="visible" append-to-body center width="760px" :before-close="handleCancel">
    <el-form ref="formDate" label-suffix=":" label-width="120px" :rules="rules" :model="form">
      <el-row>
        <el-col :span="12">
          <el-form-item label="用印公司" prop="company">
            <el-select v-model="form.company" size="small" style="width: 100%">
              <el-option
                v-for="item in companys"
                :key="item"
                :label="item"
                :value="item"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="文件名称" prop="file_name">
            <el-input v-model="form.file_name" size="small" clearable style="width: 100%" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="文件份数" prop="file_num">
            <el-input v-model="form.file_num" size="small" clearable style="width: 100%" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="用印时间" prop="use_time">
            <el-date-picker
              v-model="form.use_time"
              format="yyyy-MM-dd"
              value-format= "yyyy-MM-dd"
              type="date"
              size="small"
              clearable
              style="width: 100%"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="印章名称" prop="seal_name">
            <el-select v-model="form.seal_name" size="small" style="width: 100%">
              <el-option
                v-for="item in seals"
                :key="item"
                :label="item"
                :value="item"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="是否外带" prop="is_go">
            <el-select v-model="form.is_go" size="small" style="width: 100%">
              <el-option
                v-for="(item, index) in yn"
                :key="item"
                :label="item"
                :value="index"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="附件上传" prop="files">
            <Upload v-model="form.files" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="备注" prop="remark">
            <el-input v-model="form.remark" type="textarea" :rows="4" size="small" clearable style="width: 100%" />
          </el-form-item>
        </el-col>
        <!-- <el-col :span="24">
          <el-form-item label="抄送" prop="ccs">
            <VerifyCC v-model="form.ccs" :ccs="ccs" />
          </el-form-item>
        </el-col> -->
      </el-row>
      <el-row>
        <el-col :span="24">
          <div class="fr mt10">
            <el-button size="small" @click="handleCancel()">取 消</el-button>
            <el-button type="primary" size="small" @click="handleBeforeTo()">提 交</el-button>
          </div>
        </el-col>
      </el-row>
    </el-form>
  </el-dialog>
</template>

<script>
import Upload from '@/myComponents/Upload'
// import VerifyCC from '@/myComponents/VerifyCC'
import svf from '../../util/svf'

export default {
  components: { Upload },
  extends: svf,
  data() {
    return {
      approve_key: 'PROCESS_SEAL',
      rules: {
        company: [{ required: true, trigger: 'blur', message: '请输入用印公司' }],
        file_name: [{ required: true, trigger: 'blur', message: '请输入文件名称' }],
        file_num: [{ required: true, trigger: 'blur', message: '请输入文件份数' }],
        use_time: [{ required: true, trigger: 'blur', message: '请输入用印时间' }],
        seal_name: [{ required: true, trigger: 'blur', message: '请输入印章名称' }],
        is_go: [{ required: true, trigger: 'blur', message: '请输入是否外带' }],
        files: [{ required: true, trigger: 'blur', message: '附件不可为空' }]
      }
    }
  },
  watch: {
    visible(val) {
      if (val) {
        if(this.info.type && this.info.type === 'again'){
          this.initApply(this.info.edit)
        }else{
          this.form = this.info.edit
        }
        // this.queryCcs()
      }
    }
  },
  mounted() {
  },
  methods: {
    handleBeforeTo() {
      this.validate().then(() => {
        const e = {}
        e.files = this.form.files
        e.approve_key = this.approve_key

        e.des = '用印公司: ' + this.form.company
        e.des += ' 备注：'
        e.des += this.form.remark

        e.ccs = this.form.ccs
        e.forms = JSON.stringify(this.createForms([
          ['公司名称', this.form.company, this.form.company, 'company'],
          ['文件名称', this.form.file_name, this.form.file_name, 'file_name'],
          ['文件份数', this.form.file_num, this.form.file_num, 'file_num'],
          ['用印时间', this.form.use_time, this.form.use_time, 'use_time'],
          ['印章名称', this.form.seal_name, this.form.seal_name, 'seal_name'],
          ['是否外带', this.yn[this.form.is_go], this.form.is_go, 'is_go'],
          ['备注', this.form.remark, this.form.remark, 'remark']
        ]))
        this.handleCreate(e)
      })
    }
  }
}
</script>

<style>
</style>
